<template>
  <div class="list">
      <detailHead :title='title'></detailHead>
      <div v-if="arr.length > 0" class="none_wrap">
        <div class="list_item" v-for="(item,index) in arr " :key="index">
            <div class="title">
                <span class="blue"></span>
                <h4>{{item.bus_name}}</h4>
            </div>
                <div class="content">
                    <div class="title_con">
                        <span class="title_item">车次</span>
                        <span class="title_item">上行时间</span>
                        <span class="title_item">下行时间</span>
                    </div>
                    <div class="item" v-for="(item1,index1) in item.classes " :key="index1">
                        <div class="item_list">
                            <span class="item_t">{{index1 + 1}}</span>
                            <span class="item_t">{{item1.upstream}}</span>
                            <span class="item_t">{{item1.down}}</span>
                        </div>
                    </div>
                    <div class="tab">
                        <span>公交路线</span>
                        <span class="tab_text" v-if="item.isShow" @click="item.isShow = false">点击展开∨</span>
                        <span class="tab_text" v-else @click="item.isShow = true">点击收起∧</span>
                    </div>
                    <div class="bus_path" v-if="!item.isShow">
                        <span class="path_title">路线:</span>
                        <span v-for="(item2,index2) in item.path " :key="index2">{{item2 + '-'}}</span>
                    </div>
                </div>
        </div>
      </div>
      <div v-else class="none">
          <img src="@/assets/not-found.png" alt="">
          <span>抱歉，暂无搜索结果</span>
      </div>
            <div class="foot1">本服务由咸宁高新技术产业开发区管理委员会提供</div>
  </div>
</template>

<script>
import detailHead from "@/components/detailHead.vue";
import axios from 'axios'

export default {
    components: {
        detailHead,
    },
    data(){
        return{
            arr:[],
            isShow:true,
            title:'公交路线查询'
        }
    },
    mounted(){
        this.getList(this.$route.query.searchKey)
    },
    methods:{
        async getList(val){
            const {data:{data}} = await axios.get(
                'https://ehb-app.xngxq.cn/background/bus/query',
                {
                    params:{
                        busName:val
                    }
                }
            )
            this.arr = data.list.map((item)=>{
                item.isShow = true
                return item
            })
            console.log(333,data)
       
        },
    }
}
</script>

<style lang='less' scoped>
.list{
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-top: 15px;
    .foot1{
        color: #999999;
        font-size: 14px;
        text-align: center;
        position: fixed;
        bottom: 20px;
    }
.none_wrap{
    width: 375px;
    box-sizing: border-box;
    margin-left: 20px;
    .list_item{
        width: 90%;
        border-bottom: 1px solid #eee;
        margin-bottom: 10px;
        .title{
            display: flex;
            align-items: center;
            .blue{
                width: 5px;
                height: 20px;
                background-color: rgb(94, 188, 243);
                margin-right: 4px;
            }
            h4{
                color: rgb(83, 84, 85);
            }
        }
        .content{
            margin-left: 10px;
            margin-top: -5px;
            margin-bottom: 10px;
            color: rgb(129, 127, 127);
            padding-top: 10px;
            .tab{
                display: flex;
                justify-content: space-between;
                align-items: center;
                color: #333333;
                margin-top: 4px;
                margin-bottom: 4px;
                .tab_text{
                    color: #41a4f5;
                }
            }
            .title_con{
                display: flex;
                justify-content: space-between;
                color:#333333;
                .title_item{
                    // width: 150px;
                    color: #333;
                }
            }
            .item{
                display: flex;
                flex-direction: column;
                padding: 4px;
                .item_list{
                    display: flex;
                    justify-content: space-between;
                    border-bottom: 1px solid #eee;
                }
                .item_t{
                    font-size: 15px;
                    font-family: PingFangSC-Regular, PingFang SC;
                    font-weight: 400;
                    color: #333333;
                }
                .item_c{
                    font-size: 15px;
                    font-family: PingFangSC-Regular, PingFang SC;
                    font-weight: 400;
                    color: #999999;
                }
            }
        }
    }
}
}
.none{
    width: 70%;
    height: 70%;
    margin-top: 50%;
    color: #999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    span{
        color: #999;
        margin-top: 15px;
        font-size: 14px;
    }
}
</style>